#ifndef _NODE_CGEOHASH_HPP
#define _NODE_CGEOHASH_HPP
#include "Library.h"

#include <string>
#include <vector>

namespace GeoHash
{
    typedef std::string string_type;
    typedef std::vector<string_type> string_vector;

    struct DecodedBBox {
        double minlat, minlon, maxlat, maxlon;
    };

    struct DecodedHash {
        double latitude;
        double longitude;

        double latitude_err;
        double longitude_err;
    };

    // Encode a pair of latitude and longitude into geohash
    void GEOHASH_API encode(const double latitude, const double longitude, const size_t precision, string_type& output);

    // Encode a pair of latitude and longitude into geohash
    // All Precisions from [1 to 9] (inclusive)
    void GEOHASH_API encode_all_precisions(
        const double latitude,
        const double longitude,
        std::vector<std::string>& output);

    // Encode a pair of latitude and longitude into geohash
    // All Precisions from [min to max] (inclusive)
    void GEOHASH_API encode_range_precisions(
        const double latitude,
        const double longitude,
        const size_t min,
        const size_t max,
        std::vector<string_type>& output);


    // Decode a hash string into pair of latitude and longitude
    DecodedHash GEOHASH_API decode(const string_type& hash_string);

    // Decode hashstring into a bound box matches it
    DecodedBBox GEOHASH_API decode_bbox(const string_type& hash_string);

    // Find neighbor of a geohash string in certain direction.
    // Direction is a two-element array:
    // Ex: [ 1, 0] == north
    // Ex: [-1,-1] == southwest
    std::string GEOHASH_API neighbor(const string_type& hash_string, const int direction[]);

} // end namespace cgeohash

#endif /* end hpp */
